package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Xinfangxinxi;
import com.ruoyi.system.service.IXinfangxinxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信访信息表Controller
 * 
 * @author Quilan
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/xinfangxinxi")
public class XinfangxinxiController extends BaseController
{
    @Autowired
    private IXinfangxinxiService xinfangxinxiService;

    /**
     * 查询信访信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Xinfangxinxi xinfangxinxi)
    {
        startPage();
        List<Xinfangxinxi> list = xinfangxinxiService.selectXinfangxinxiList(xinfangxinxi);
        return getDataTable(list);
    }

    /**
     * 导出信访信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:export')")
    @Log(title = "信访信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xinfangxinxi xinfangxinxi)
    {
        List<Xinfangxinxi> list = xinfangxinxiService.selectXinfangxinxiList(xinfangxinxi);
        ExcelUtil<Xinfangxinxi> util = new ExcelUtil<Xinfangxinxi>(Xinfangxinxi.class);
        util.exportExcel(response, list, "信访信息表数据");
    }

    /**
     * 获取信访信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xinfangxinxiService.selectXinfangxinxiById(id));
    }

    /**
     * 新增信访信息表
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:add')")
    @Log(title = "信访信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xinfangxinxi xinfangxinxi)
    {
        return toAjax(xinfangxinxiService.insertXinfangxinxi(xinfangxinxi));
    }

    /**
     * 修改信访信息表
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:edit')")
    @Log(title = "信访信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xinfangxinxi xinfangxinxi)
    {
        return toAjax(xinfangxinxiService.updateXinfangxinxi(xinfangxinxi));
    }

    /**
     * 删除信访信息表
     */
    @PreAuthorize("@ss.hasPermi('system:xinfangxinxi:remove')")
    @Log(title = "信访信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xinfangxinxiService.deleteXinfangxinxiByIds(ids));
    }
}
